{template 'web/_header'}
{template 'web/member/tabs'}

{if $operation == 'post'}
<div class="main">
    <form {ife 'member.group' $group}action="" method="post"{/if} class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$group['id']}" />
        <div class='panel panel-default'>
            <div class='panel-heading'>
                会员分组设置
            </div>
            <div class='panel-body'>
               
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 分组名称</label>
                    <div class="col-sm-9 col-xs-12">
                         {ife 'member.group' $group}
                        <input type="text" name="groupname" class="form-control" value="{$group['groupname']}" />
                        {else}
                        <div class='form-control-static'>{$group['groupname']}</div>
                        {/if}
                    </div>
                </div>
                
                 <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'member.group' $group}
                            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
                            <input type="hidden" name="token" value="{$_W['token']}" />
                        {/if}
                       <input type="button" name="back" onclick='history.back()' {ifp 'member.group.add|member.group.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
                    </div>
                </div>
                
                
            </div>
        </div>
  
    </form>
</div>
<script language='javascript'>
    $('form').submit(function(){
        if($(':input[name=groupname]').isEmpty()){
            Tip.focus($(':input[name=groupname]'),'请输入分组名称!');
            return false;
        }
        return true;
    })
    </script>
{elseif $operation == 'display'}
               <form action="" method="post" onsubmit="return formcheck(this)">
     <div class='panel panel-default'>
            <div class='panel-heading'>
                会员分组设置
            </div>
         <div class='panel-body'>

            <table class="table">
                <thead>
                    <tr>
                        <th>分组名称</th>
                        <th>会员数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td>{$row['groupname']}</td>
                        <td>{$row['membercount']}</td>
                        <td>
                            <a class='btn btn-default' href="{php echo $this->createWebUrl('member', array('groupid' => $row['id']))}"><i class='fa fa-users'></i></a>
                            {if !empty($row['id'])}
                            {ifp 'member.group.add|member.group.view'}
                                <a class='btn btn-default' href="{php echo $this->createWebUrl('member/group', array('op' => 'post', 'id' => $row['id']))}"><i class='fa fa-edit'></i></a>
                            {/if}
                            {ifp 'member.group.delete'}
                               <a class='btn btn-default'  href="{php echo $this->createWebUrl('member/group', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此会员分组吗？');return false;"><i class='fa fa-remove'></i></a></td>
                            {/if}
                            {/if}
                        

                    </tr>
                    {/loop}
                 
                </tbody>
            </table>
  
         </div>
         {if 'member.group.add'}
           <div class='panel-footer'>
                            <a class='btn btn-default' href="{php echo $this->createWebUrl('member/group', array('op' => 'post'))}"><i class="fa fa-plus"></i> 添加新分组</a>
         </div>
         {/if}
     </div>
       </form>
{/if}
{template 'web/_footer'}
